# -*- coding: utf-8 -*-



class Translator:

    def __init__(self):
        tr = {}
        tr['Nota'] = 'Note'
        tr['Preliminares'] = 'Prelims'
        tr['Cubierta anterior'] = 'Front cover'
        tr['Lomo'] = 'Spine'
        tr['Reverso cubierta anterior'] = 'Reverse front cover'
        tr['Guarda anterior'] = 'Front flyleaf'
        tr['Reverso guarda anterior'] = 'Reverse front flyleaf'
        tr[u'Título'] = 'Title'
        tr[u'Reverso título'] = 'Reverse title'
        tr[u'Antetítulo'] = 'Half-title'
        tr[u'Reverso antetítulo'] = 'Reverse half-title'
        tr['Fecha'] = 'Date'
        tr[u'Índice'] = 'Index'
        tr['Dedicatoria'] = 'Dedication'
        tr['Finales'] = 'Finals'
        tr['Reverso guarda posterior'] = 'Reverse back flyleaf'
        tr['Guarda posterior'] = 'Back flyleaf'
        tr['Reverso cubierta posterior'] = 'Reverse back cover'
        tr['Cubierta posterior'] = 'Back cover'
        tr[u'[Vacío]'] = '[Empty]'
        self.trComplete = tr
        tr = []
        tr.append((u'Cedido para su digitalización por el', 'Allowed to be digitized by the'))
        tr.append((u'Cedido para su digitalización por', 'Allowed to be digitized by'))
        tr.append(('(Mapa)', '(Map)'))
        self.trPartial = tr



    def translate(self, string):
        for (spanish, english) in self.trComplete.items():
            if string == spanish:
                string = string.replace(spanish, english)
        for (spanish, english) in self.trPartial:
            string = string.replace(spanish, english)
        return string



